<template>
    <div class="my">
      <!-- <div class="title" @click="myClick">我的</div> -->
      <div @click="toLogin" class="login" v-if="!userStore.isLogin" >去登录</div>
      <div @click="handleLogout" class="logout" v-else>退出登录</div>
    </div>
  </template>
  <script setup  lang="ts">
    import { ref } from 'vue';
    import { useUserStore } from '@/stores';
    import { useRouter } from 'vue-router';
    const router = useRouter();
    const userStore = useUserStore();
    const toLogin = () => {
      router.push('/login');
    };
    // 新增退出登录方法
    const handleLogout = () => {
      userStore.logout();
      router.replace('/login'); // 退出后跳转登录页
    };
    const myClick = () => {
      console.log('isLogin',userStore.isLogin);
      console.log('token',userStore.token);
    };
  </script>
  <style>
  @media (min-width: 1024px) {
    .my {
      min-height: 100vh;
      display: flex;
      align-items: center;
    }
  }
  </style>
  